<template>
	<view class="cancellationoforder">
		<view class="cancellationoforder_box">
			<view class="cancellationoforder_box_top">
				<view class="cancellationoforder_box_top_shang">请输入取消订单原因</view>
				<!-- <view class="cancellationoforder_box_zhong">
					<view class="cancellationoforder_box_zhong_a">
						<radio-group class="radio-group" @change="radioChange">
							<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items"
								:key="item.value">
								<view class="view">
									<radio :value="item.value" style="transform:scale(0.6)"
										:checked="index === current" />
								</view>
								<text>{{item.name}}</text>
							</label>
						</radio-group>

					</view>

				</view> -->

				<view class="wenben">
					<textarea v-model="reason" class="ipt"></textarea>
				</view>
			</view>
			<view class="cancellationoforder_box_bottom" @click="gocancel">
				提交
			</view>
		</view>
	</view>
</template>

<script>
	import homeServices from '../../service/homeService'
	export default {
		data() {
			return {
				items: [{
						value: 1,
						name: '无法接单',
					},
					{
						value: 2,
						name: '联系不到客户'
					}
				],
				current: 0,
				id:'',
				reason:'',
				status:''
			}
		},
		onLoad(option) {
			this.id = option.id
			this.status = option.status
		},
		methods: {
			radioChange(e) {
				console.log(e)
			},
			async gocancel(){
				console.log(this.reason);
				if(this.reason.trim() == ''){
					uni.showToast({
						title:'请输入取消原因',
						icon:'none'
					})
					return
				}
				if(this.status==0){
					let params = {
						orderCode: this.id,
						cancelReson:this.reason
					}
					let res = await homeServices.refund(params)
					uni.showToast({
						title:'已提交，等待审核',
						icon:'none'
					})
					setTimeout(()=>{
						uni.navigateBack()
					},1000)
				}
				if(this.status==50){
					let params = {
						id: this.id,
						cancelReson:this.reason
					}
					let res = await homeServices.cancelOrder(params)
					uni.showToast({
						title:'取消成功',
						icon:'none'
					})
					setTimeout(()=>{
						uni.navigateBack()
					},1000)
				}
				
			}
			
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/sass/cancellationoforder.scss'
</style>
